package leetcode;

import cn.hutool.core.util.StrUtil;

/**
 * 版本工具类
 */
public class VersionUtil {

    public static void main(String[] args) {
        System.out.println(generateVersion("1.0.9"));
    }

    public static String generateVersion() {
        return "1.0.0";
    }

    public static String generateVersion(String oldVersion) {
        if (StrUtil.isEmpty(oldVersion)) {
            return generateVersion();
        }
        String[] split = oldVersion.split("\\.");
        int one = Integer.parseInt(split[0]);
        int two = Integer.parseInt(split[1]);
        int three = Integer.parseInt(split[2]);
        if (three + 1 > 99) {
            if (two + 1 > 99) {
                one = one + 1;
                two = 0;
                three = 0;
            } else {
                two = two + 1;
                three = 0;
            }
        } else if (two + 1 > 99) {
            one = one + 1;
            two = 0;
        } else {
            three = three + 1;
        }
        return one + "." + two + "." + three;
    }
}
